import matplotlib.pyplot as plt
from random import Random
from Utils import sigmoid,gaussian,logistic_sigmoid
from time import time


class HDRGenerator:
    '''
    Classdocstring
    '''

    def __init__(self):
        pass

    def generate_hdr(self, args):
        pass

    def plot_default(self, numcols):
        pass


class UniformSigmoidHDRGenerator(HDRGenerator):

    #TODO: Figure out how to make intercept, slope private instance variables
    def __init__(self, intercept, slope):
        self.intercept = intercept
        self.slope = slope

    def generate_hdr(self, args):
        r = Random(time())
        if type(args) is int:
            return [sigmoid((r.random(),self.intercept,self.slope)) for val in range(args)]
        elif len(args) > 0:
            return [val + gaussian(None) for val in args]

    def plot_default(self, numcols):
        r = Random(time())
        t = [r.random() for val in range(numcols)]
        hdr = sorted([sigmoid(val) for val in t])
        plt.plot(t,hdr,"ro")
        plt.show()


class GaussianLogisticSigmoidHDRGenerator(HDRGenerator):

    #TODO: Figure out how to make stdev private instance variables
    def __init(self, stdev):
        self.stdev = stdev

    def generate_hdr(self, args):
        r = Random(time())
        if type(args) is int:
           return [logistic_sigmoid(r.random()) for val in range(args)]
        elif len(args) > 0:
           return [val + gaussian(0.0,self.stdev) for val in args]
